<?php
include_once '../controlador_bd/CConexion.php';
include_once '../clases_dominio/CSolicitudExamen.php';
//include_once '../clases_dominio/CResultadoExamen.php';

$objConexion = new CConexion;
$objConexion -> conectar();
$consulta = "select 
				distinct t1.codigoorden, 
				t2.nombreexa, 
				to_char(t1.fechaorden, 'DD/MM/YYY') as fecha, 
				t1.totalapagar 
			from 
				ordendeexamen t1, examen  t2 
			where 
				fechaorden = current_date and t1.codigoexa = t2.codigoexa  order by t1.codigoorden asc";
$resultado = pg_query($consulta);
$fila = pg_fetch_all($resultado);

$consultaTotal = "select 
					sum(totalapagar) as total 
				  from 
				  	ordendeexamen 
				  where 
				  	fechaorden = current_date";
$resultadoTotal = pg_query($consultaTotal);
$filaTotal = pg_fetch_array($resultadoTotal);


$conTotalExa = "select 
					count(ordendeexamen) as total 
				  from 
				  	ordendeexamen 
				  where 
				  	fechaorden = CURRENT_DATE;";
$pgConTotalExa = pg_query($conTotalExa);
$totalExa = pg_fetch_array($pgConTotalExa);
 
?>

<!DOCTYPE HTML>
<html>
	<head></head>
	<body>
		<div class="row">
			<p style="margin-top: 1.25em;">
				Exámenes realizados este día
			</p>
			<table class="large-12 columns">
				<thead>
					<tr>
						
						<th>Examen Prácticado</th>
						<th>Nro. Orden</th>
						<th>Total a Pagar</th>

					</tr>
				</thead>
				<tbody>
					<?php
					for ($i = 0; $i < count($fila); $i++) { echo "
<tr>

<td>" . $fila[$i]['nombreexa'] . "</td>
<td>" . $fila[$i]['codigoorden'] . "</td>
<td> $" . $fila[$i]['totalapagar'] . "</td>

</tr>";
					}
					?>
				</tbody>
				<tfoot>
					
					
					
					<th>TOTAL</th>
					<th><?php
					echo  $totalExa['total']." Examenes";
					?></th>
					<th><?php
					echo "$" . $filaTotal['total'];
					?></th>
				</tfoot>
			</table>
			<div class="row">
			<div class="large-8 columns">
				<!-- <input id='agregar' class="small button success" type="button" value="Imprimir"  onclick="cargarImprimirOrdenMes();"> -->
				<a class="small button" href="../formularios_manejadores/imprimir_examenes_dia.php"  value="Cancelar">Generar PDF</a>
			</div>
		</div>
		</div>
		
	</body>
</html>